package com.cxx.purchasecharge.service;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import com.cxx.purchasecharge.core.model.CustomerTypeCode;
import com.cxx.purchasecharge.core.model.OrderSearchForm;
import com.cxx.purchasecharge.core.model.OrderTypeCode;
import com.cxx.purchasecharge.core.model.persistence.Contact;
import com.cxx.purchasecharge.core.model.persistence.Customer;
import com.cxx.purchasecharge.core.model.persistence.Goods;
import com.cxx.purchasecharge.core.model.persistence.GoodsType;
import com.cxx.purchasecharge.core.model.persistence.Order;
import com.cxx.purchasecharge.core.model.persistence.OrderItem;

public interface QueryService
{
    Contact getContact (long id);

    Contact getContact (String name);

    Page <Contact> findContactByFuzzy (Pageable pageable, String searchKey, String signUser, boolean admin);

    Customer getCustomer (long id);

    Customer getCustomer (String name);

    Customer getCustomerByContact (long contactId);

    List <Customer> getAllCustomer (CustomerTypeCode type, String signUser, boolean admin);

    Page <Customer> findByFuzzy (CustomerTypeCode typeCode, Pageable pageable, String searchKey, String signUser,
                                 boolean admin);
    
    float countCustomerUnpay (CustomerTypeCode typeCode, String searchKey, String signUser,
                              boolean admin);

    Page <Customer> findCustomerByFuzzy (Pageable pageable, String searchKey, String signUser, boolean admin);

    Order findOrderById (long id);

    List <OrderItem> findOrderItemByOrder (Order order);
    List <OrderItem> findOrderItemWithOrder (long orderId);

    Page <Order> findOrderByFuzzy (OrderTypeCode typeCode, Pageable pageable, String searchKey, String signUser,
                                   boolean admin);

    Page <Order> findOrderBySearchForm (OrderTypeCode typeCode, Pageable pageable, OrderSearchForm searchForm,
                                        String signUser, boolean admin);
    
    Page <Order> findOrderBySearchForm (boolean isOut, Pageable pageable, OrderSearchForm searchForm,
                                        String signUser, boolean admin);

    float countOrderReceivableBySearchForm (OrderTypeCode typeCode, OrderSearchForm searchForm,
                                         String signUser, boolean admin);
    
    float countOrderProfitBySearchForm (OrderTypeCode typeCode, OrderSearchForm searchForm,
                                       String signUser, boolean admin);

    List <Order> getOrderByCustomer (long customerId);

    List <OrderItem> getOrderItemByOrder (Order order);

    List <OrderItem> getOrderItemByGoods (long goodsId);

    Goods getGoods (String name);

    List <Goods> getGoods (GoodsType type);
    
    long getUniqueIdByUserId (String userId);
}
